package com.tozed.test;

import com.tozed.widget.TitleBar;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.util.Log;

public class TouchTestMultiple extends Activity  implements OnClickListener {
	
    private static final String TAG = "TouchTestMultiple";
    
    private TextView mTextTip = null;
    private ViewTouchMultiple mView = null;

    private TitleBar mTitleBar;
	private Button mBtnPass, mBtnFail;
	
    private ViewTouch.onCompletedListener mListener = new ViewTouch.onCompletedListener() {
        @Override
        public void onCompleted(View v) {
        	mBtnPass.setVisibility(View.VISIBLE);
        	mBtnPass.performClick();
        }
    };
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
		Log.v(TAG, "onCreate");
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.test_touch_multiple);

        mTextTip = (TextView)findViewById(R.id.text_tip);
        mTextTip.setText(R.string.str_touch_multiple_notice);
        
        mView = (ViewTouchMultiple)findViewById(R.id.view_touch_multiple);
        mView.setOnCompletedListener(mListener);
        
        mTitleBar = (TitleBar)findViewById(R.id.title_bar);
		mTitleBar.setTiteText(R.string.str_test_touchpanel);
		mTitleBar.hideLeftButton();
		mTitleBar.hideRightButton();
		
		mBtnPass = (Button)findViewById(R.id.btn_pass);
		mBtnFail = (Button)findViewById(R.id.btn_fail);
		
		mBtnPass.setText(R.string.str_finish);
		mBtnPass.setOnClickListener(this);
		mBtnFail.setOnClickListener(this);
		mBtnPass.setVisibility(View.INVISIBLE);
    }
    
    @Override
    protected void onResume() {
        super.onResume();
    }
    
    @Override
    protected void onPause() {
        super.onPause();
    }
    
    @Override
    protected void onDestroy() {
        super.onDestroy(); 
    }
    
    @Override
	public void onClick(View v) {
		if (mBtnPass == v) {
            setResult(Activity.RESULT_OK);
            finish();
		} else if (mBtnFail == v) {
            setResult(Activity.RESULT_CANCELED);
            finish();
		}
	}
}


